package com.cdx.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author chedx
 * @data 2020/12/7 7:57 PM
 */
@Configuration
public class RoutConfig {
    @Bean
    public RouteLocator customRoutLocator(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder routes = builder.routes();
        RouteLocator routeLocator = routes.route("path_rout_001", r -> r.path("/guonei").uri("http://news.baidu.com/guonei")).build();
        return routeLocator;
    }

    @Bean
    public RouteLocator customRoutLocator2(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder routes = builder.routes();
        RouteLocator routeLocator = routes.route("path_rout_002", r -> r.path("/mil").uri("http://news.baidu.com/mil")).build();
        return routeLocator;
    }
}
